package com.example.sls.mapper.account;

import com.example.sls.pojo.account.Account;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

@Mapper
@Repository
public interface AccountMapper {

    //添加一个用户账号到account表中
    @Insert("insert into account(id,username,password, phone, email, roleId) values (#{id}, #{username}, #{password},#{phone}, #{email}, #{roleId});")
    Integer addAccount(Account account);

    //根据id重置密码
    @Update("update account set password = #{password} where id = #{id};")
    Integer resetPassword(String password, Integer id);

    //更改account表中的基本账号信息
    @Update("update account set username = #{username}, phone = #{phone}, email = #{email} where id = #{id};")
    Integer updateAccount(Map<String , Object > account);

    //删除account表中的账号信息
    @Delete("delete from account where id = #{id};")
    Integer deleteAccount(@Param("id") Integer id);

    //根据id查询account表中的账号信息
    @Select("select * from account where id = #{id};")
    Account getAccountById(@Param("id") Integer id);

    //根据username查询account表中的账号信息
    @Select("select * from account where username = #{username};")
    Account getAccountByUserName(@Param("username") String  username);

    //查询account表中的所有账号信息
    @Select("select * from account")
    List<Account> getAllAccount();

    //查询account表中的账号数量
    @Select("select count(*) from account;")
    Integer getCount();

    //查询account表中最大的id
    @Select("select max(id) from account;")
    Integer getMaxId();



}
